<?php

use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Role;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        factory(User::class, 50)->create();

        $users = User::all();
        foreach ($users as $user) {
            if ($user->id === 1) {
                $user->update(['name' => 'admin']);
                $user->assignRole(Role::find(1));
            } else if ($user->id === 2) {
                $user->assignRole(Role::find(2));
            } else {
                $user->assignRole(Role::find(4));
                $user->update(['uid' => 2]);
            }
        }
    }
}
